# include <iostream>
# include <vector>
# include <cstdio>
# define MAXN (int)(1e5 + 5)
using namespace std;

inline char getc() { 
    static char buf[1 << 18], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

# define getc() getchar()

inline int gn() { 
    register int k = 0, f = 1;
    char c = getc();
    for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
    for(; isdigit(c); c = getc()) k = k * 10 + c - '0';
    return k * f;
}

vector<int> to[MAXN];
int n, a[MAXN], dfn[MAXN], cnt, siz[MAXN], adfn[MAXN];

struct node { 
    int mi, mx;
    int lz;
    node *ls, *rs;
    node() { 
        mi = 0x7fffffff;
        ls = rs = NULL;
        lz = 0;
    }
}*root;


# define mid ((l + r) >> 1)

node *build(int l, int r) { 
    node *x = new node();
    if(l ^ r) { 
        x->ls = build(l, mid);
        x->rs = build(mid + 1, r);
        x->mx = max(x->ls->mx, x->rs->mx);
        x->mi = min(x->ls->mi, x->rs->mi);
    } else {
        x->mi = x->mx = adfn[l];
    }
    return x;
}

void dfs(int x) {
    dfn[x] = ++cnt;
    adfn[cnt] = x;
    siz[x] = 1;
    for(unsigned int i = 0; i < to[x].size(); i++) { 
        dfs(to[x][i]);
        siz[x] += siz[to[x][i]];
    }
}

void change(node *x, int l, int r, int s, int t, int k) {
    if(x->lz) {
        change(x->ls, s, mid, s, mid, x->lz);
        change(x->rs, mid + 1, r, mid + 1, r, x->lz);
        x->lz = 0;
    }
    x->mx -= k;
    x->mi -= k;
    if(l == s && r == t) {
        if(l ^ r) {
            x->lz += k;
        }
        return;
    }
    if(t <= mid) change(x->ls, l, mid, s, t, k);
    else if(s > mid) change(x->rs, mid + 1, r, s, t, k);
    else change(x->ls, l, mid, s, mid, k), change(x->rs, mid + 1, r, mid + 1, t, k);
}

int query(node *x, int l, int r, int s, int t) { 
    if(x->lz) {
        change(x->ls, s, mid, s, mid, x->lz);
        change(x->rs, mid + 1, r, mid + 1, r, x->lz);
        x->lz = 0;
    }
    if(l == s && r == t) {
        if(x->mi > 0) return r - l + 1;
        else if(x->mx <= 0) return 0;
        else return query(x->ls, s, mid, s, mid) + query(x->rs, mid + 1, t, mid + 1, t);
    }
    if(t <= mid) return query(x->ls, l, mid, s, t);
    else if(s > mid) return query(x->rs, mid + 1, r, s, t);
    else return query(x->ls, l, mid, s, mid) + query(x->rs, mid + 1, r, mid + 1, t);
}
/*
    初步构思
    当max<= 0 返回0
    当min >= 0 返回r - l + 1
    不用维护sum
*/

int main() { 
    n = gn();
    for(int i = 1; i <= n; i++) {
        a[i] = gn();
        to[gn()].push_back(i);
    }
    dfs(0);
    n++;
    root = build(1, n);
    int m = gn();
    for(int i = 1, a, x; i <= m; i++) {
        if(gn() & 1) {
            a = gn(), x = gn();
            change(root, 1, n, dfn[a] + 1, dfn[a] + siz[a] - 1, x);
        } else {
            a = gn();
            printf("%d\n", query(root, 1, n, dfn[a] + 1, dfn[a] + siz[a] - 1));

        }
    }
}
/*
 * 4
 * 1 0
 * 2 0
 * 2 2
 * 1 2
 *
 * pot:
 *         0
 *        / \
 *       1   2
 *          / \
 *         3   4
 *
 * dfn:
 *         1
 *        / \
 *       2   3
 *          / \
 *         4   5
 *
 * siz:
 *         5
 *        / \
 *       1   3
 *          / \
 *         1   1
 *
 */